import 'package:gold/generated/json/base/json_field.dart';
import 'dart:convert';

import 'package:gold/generated/json/review_list_model.g.dart';

/// 评论列表
@JsonSerializable()
class ReviewListModel {
	List<ReviewModel>? data;
	int? total;
	int? count;
	@JSONField(name: 'per_page')
	int? perPage;
	@JSONField(name: 'current_page')
	int? currentPage;
	@JSONField(name: 'total_pages')
	int? totalPages;

	ReviewListModel();

	factory ReviewListModel.fromJson(Map<String, dynamic> json) => $ReviewListModelFromJson(json);

	Map<String, dynamic> toJson() => $ReviewListModelToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}
}

@JsonSerializable()
class ReviewModel {
	/// 评论ID
	int? id;
	/// 用户id
	@JSONField(name: 'user_id')
	int? userId;
	/// 评分
	int? rating;
	/// 是否匿名评价：0=不匿名，1=匿名
	@JSONField(name: 'is_private')
	int? isPrivate;
	/// 评论内容
	String? comment;
	/// 图片集合，用英文逗号分隔
	String? images;
	/// 用户信息
	MemberModel? member;

	ReviewModel();

	factory ReviewModel.fromJson(Map<String, dynamic> json) => $ReviewModelFromJson(json);

	Map<String, dynamic> toJson() => $ReviewModelToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}
}

@JsonSerializable()
class MemberModel {
	/// 用户id
	int? uid;
	/// 昵称
	String? nickname;
	/// 头像
	String? avatar;

	MemberModel();

	factory MemberModel.fromJson(Map<String, dynamic> json) => $MemberModelFromJson(json);

	Map<String, dynamic> toJson() => $MemberModelToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}
}